package com.tianquan.springspi.redis;/**
 * @author starsea
 * @date 2024-09-20 下午8:33
 */

import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

/**
 *@BelongsProject: uploaddemo
 *@BelongsPackage: com.tianquan.springspi.redis
 *@Author: tianquan
 *@CreateTime: 2024-09-20  20:33
 *@Description: 测试
 *@Version: 1.0
 */
public class test {
    public static void main(String[] args) {
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://127.0.0.1:6379");
        RedissonClient redissonClient = Redisson.create(config);

        // 创建锁对象
        RLock redisLock = redissonClient.getLock("lock:order:" + 1);
        // 尝试获取锁
        redisLock.lock();

        redisLock.unlock();


    }
}
